<script setup>
import HomePinal from "./HomePinal.vue";
import { getNewGoodsApi } from "@/api/home";
import { ref, onMounted } from "vue";

const newList = ref([]);

onMounted(async () => {
  const res = await getNewGoodsApi();

  newList.value = res.result;
});
</script>

<template>
  <HomePinal title="新鲜好物" small="新鲜出炉 品质靠谱">
    <template #hed> 查看全部 > </template>
    <template #mid>
      <ul class="new-list">
        <li v-for="item in newList" :key="item.id">
          <img :src="item.picture" alt="" />
          <p class="name">{{ item.name }}</p>
          <p class="price"><i>¥</i>{{ item.price }}</p>
        </li>
      </ul>
    </template>
  </HomePinal>
</template>

<style>
.new-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: space-between;
  li {
    width: 303px;
    height: 403px;
    background: #f0f9f4;
    transition: all 0.5s;

    &:hover {
      transform: translate3d(0, -3px, 0);
      box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    }
    .name {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: #cf4444;
      font-size: 24px;
      text-align: center;
    }
  }
}
</style>
